<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css"/>
    <link href="__STATIC__/admin/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/typeahead-bs2.min.js"></script>
    <script src="__STATIC__/admin/js/lrtk.js" type="text/javascript" ></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript" ></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/swfupload/swfupload.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/swfupload/swfupload.queue.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/swfupload/swfupload.speed.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/ueditor/1.4.3/ueditor.all.min.js"> </script>

    <title>新闻管理</title>
</head>

<body>
<div class="Guestbook_style">
    <form action="{:url('index')}" method="get">
    <div class="search_style">
        <div class="title_names">搜索查询</div>
        <ul class="search_content clearfix">
            <li><label class="l_f">标题</label><input name="title" type="text" class="text_add" placeholder="输入标题信息" style=" width:250px"></li>

            <li style="width:90px;"><button type="sibmit" class="btn_search"><i class="icon-search"></i>查询</button></li>
        </ul>
    </div>
    </form>
<div class=" clearfix" id="advertising">
    <div id="scrollsidebar" class="left_Treeview">
        <div class="show_btn" id="rightArrow"><span></span></div>
        <div class="widget-box side_content" >
            <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
            <div class="side_list">
                <div class="widget-header header-color-green2">
                    <h4 class="lighter smaller">新闻分类</h4>
                </div>
                <div class="widget-body">
                    <ul class="b_P_Sort_list">

                        <li><i class="orange  fa fa-user-secret"></i><a href="{:url('index')}">全部</a></li>
                        {foreach $newscat as $v}
                        <li><i class="fa fa-image pink "></i> <a href="{:url('index',['op'=>'cate','id'=>$v.catid])}">{$v.cate_name}</a></li>

                        {/foreach}
                    </ul>
                </div>
            </div>
        </div>
    </div><div class="Ads_list">
    <div class="border clearfix">
       <span class="l_f">
           <a href="{:url('create')}" class="btn btn-warning"><i class="fa fa-plus"></i> 添加新闻</a>
<!--        <a href="javascript:ovid()" id="ads_add" class="btn btn-warning"><i class="fa fa-plus"></i> 添加新闻</a>-->
        <a href="javascript:;" data-url="{:url('delete',['op'=>'delall'])}" class="btn btn-danger" id="patch_delete"><i class="fa fa-trash"></i> 批量删除</a>
       </span>
        <span class="r_f">共：<b>{$list->total()}</b>条新闻</span>
    </div>
    <div class="Ads_lists">
        <form action="" method="post">
        <table class="table table-striped table-bordered table-hover" id="sample-table">
            <thead>
            <tr>
                <th width="25"><label><input name="" type="checkbox" value=""></label></th>
                <th width="80">ID</th>
                <th>排序</th>
                <th width="100">分类</th>
                <th width="150px">新闻标题</th>
                <th width="240px">缩略图</th>
                <th width="250px">链接地址</th>
                <th width="180">添加时间</th>
                <th width="70">状态</th>
                <th width="250">操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $list as $v}
            <tr>
                <td><label><input name="" type="checkbox" value=""></label></td>
                <td>{$v.id}</td>
                <td><input name="{$v.id}" type="text"  value="{$v.displayorder}" style=" width:50px" placeholder="1"/></td>
                <td>{$v.catid|getNewName}</td>
                <td>{$v.title}</td>
                <td><span class="ad_img"><img src="{$v.headimg}"  width="100%" height="100%"/></span></td>

                <td><a href="javascript:void(0)" >http://item.jd.com/10443270082.html</a></td>
                <td>{$v.create_time|getFormatTime}</td>
                {if($v.status eq 1)}
                <td class="td-status"><span class="label label-success radius">已显示</span></td>
                {else /}
                <td class="td-status"><span class="label label-defaunt radius">已隐藏</span></td>
                {/if}

                <td class="td-manage">
                    {if($v.status eq 1)}
                    <a  href="{:url('stop',['id'=>$v.id])}"    title="隐藏"  class="btn btn-xs"><i class="fa  fa-eye-slash  bigger-120"></i></a>

                    {else /}
                    <a  href="{:url('stop',['id'=>$v.id])}"  title="显示"  class="btn btn-xs btn-success show-status"><i class="fa fa-eye bigger-120"></i></a>

                    {/if}
                    <a title="编辑"  href="{:url('edit',['id'=>$v.id])}"  class="btn btn-xs btn-info"><i class="fa fa-edit bigger-120"></i></a>
                    <a title="删除" href="javascript:;"  data-url="{:url('delete',['id'=>$v.id])}"  class="btn btn-xs btn-warning delete" ><i class="fa fa-trash  bigger-120"></i></a>
<!--                    <a title="删除" href="{:url('delete',['id'=>$v.id])}"  class="btn btn-xs btn-warning delete" ><i class="fa fa-trash  bigger-120"></i></a>-->
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
            <div><input class="btn btn-primary btn-sm shiny" style="margin-left:124px; margin-top:10px;" type="submit" value="排序" ></div>
        </form>
        <div class="pd-20">{$list->render()}</div>
    </div>

</div>
</div>
<!--添加新闻样式-->
<!--<div id="add_ads_style"  style="display:none">-->
<!--    <form action="{:url('save')}" method="post" enctype='multipart/form-data'>-->
<!--    <div class="add_adverts">-->
<!--        <ul>-->
<!--            <li>-->
<!--                <label class="label_name">所属分类</label>-->
<!--                <span class="cont_style">-->
<!--  <select class="form-control" name="catid">-->
<!--    {foreach $newscat as $v}-->
<!--    <option value="{$v.catid}">{$v.cate_name}</option>-->
<!--    {/foreach}-->
<!--  </select></span>-->
<!--            </li>-->
<!--            <li><label class="label_name">新闻标题</label><span class="cont_style">-->
<!--  <input name="title" type="text"  placeholder="输入新闻标题" class="col-xs-10 col-sm-5" >-->

<!--            <li><label class="label_name">显示排序</label><span class="cont_style"><input name="diplayorder" type="text" placeholder="输入排序"  class="col-xs-10 col-sm-5" ></span></li>-->
<!--            <li><label class="label_name">封面图</label><span class="cont_style" style="margin-left:10px;"> <input type="file" name="face" ></span></li>-->
<!--            <li><label class="label_name">描述</label><span class="cont_style">-->


<!--          <textarea name="description" cols="80" rows="7"   placeholder="新闻描述..." datatype="*10-100" dragonfly="true" title="新闻描述" onKeyUp="textarealength(this,500)"></textarea>-->
<!--          <p class="textarea-numberbar"><em class="textarea-length">0</em>/500</p>-->


<!--            </span>-->
<!--            </li>-->
<!--            <li><label class="label_name">详情</label><span class="cont_style">-->

<!--	          <div style="width:620px;margin-left:10px;">-->
<!--          <script id="editor" type="text/plain" style="width:100%;height:400px;"></script>-->
<!--           </div>-->

<!--            </span>-->
<!--            </li>-->
<!--            <li>-->
<!--                <div class="Button_operation">-->
<!--                        <button class="btn btn-primary radius" type="submit"><i class="icon-save "></i>保存并提交</button>-->
<!--                        <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>-->
<!--                    </div>-->
<!--            </li>-->

<!--        </ul>-->

<!--   </div>-->
<!--    </form>-->
<!--</div>-->
</body>
</html>
<script>
    $(function(){
    var ue = UE.getEditor('editor');
});

    //初始化宽度、高度
    $(".widget-box").height($(window).height());
    $(".Ads_list").width($(window).width()-220);
    //当文档窗口发生改变时 触发
    $(window).resize(function(){
        $(".widget-box").height($(window).height());
        $(".Ads_list").width($(window).width()-220);
    });
    $(function() {
        $("#advertising").fix({
            float : 'left',
            //minStatue : true,
            skin : 'green',
            durationTime :false,
            stylewidth:'220',
            spacingw:30,//设置隐藏时的距离
            spacingh:250,//设置显示时间距
            set_scrollsidebar:'.Ads_style',
            table_menu:'.Ads_list'
        });
    });
    /*广告图片-停用*/
    function member_stop(obj,id){
        layer.confirm('确认要关闭吗？',{icon:0,},function(index){
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="显示"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已关闭</span>');
            $(obj).remove();
            layer.msg('关闭!',{icon: 5,time:1000});
        });
    }
    /*广告图片-启用*/
    function member_start(obj,id){
        layer.confirm('确认要显示吗？',{icon:0,},function(index){
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="关闭"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<td class="td-status"><span class="label label-defaunt radius">已隐藏</span></td>');
            $(obj).remove();
            layer.msg('显示!',{icon: 6,time:1000});
        });
    }
    /*广告图片-删除*/
    $('.delete').click(function(){
        var obj = this;
        layer.confirm('删除须谨慎，确认要删除吗？',function(index){
            var url = $(obj).attr('data-url');
            $.ajax({
                "url":url,
                "type":'post',
                "dataType":"json",
                "success":function(res){
                    if(res.code == 200){
                        $(obj).closest("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg('删除失败：' + res.msg);
                    }
                }
            });


        });
    });

    //批量删除
    $('#patch_delete').click(function(){
        var obj = this;
        layer.confirm('删除须谨慎，确认要删除吗？',function(index){
            var url = $(obj).attr('data-url');
            var ids = [];
            $('.row_check:checked').each(function(i,v){
                ids.push($(v).val());
            });
            var data = {"id":ids.join(',')};
            $.ajax({
                "url":url,
                "type":'post',
                "data":data,
                "dataType":"json",
                "success":function(res){
                    if(res.code == 200){
                        $('.row_check:checked').closest('tr').remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        // layer.msg('删除失败：' + res.msg);
                        console.log(res.msg);
                    }
                }
            });


        });
    });

    /*******添加广告*********/
    $('#ads_add').on('click', function(){
        layer.open({
            type: 1,
            title: '添加新闻',
            maxmin: true,
            shadeClose: false, //点击遮罩关闭层
            area : ['800px' , ''],
            content:$('#add_ads_style')

        });
    })
</script>
<script type="text/javascript">
    function updateProgress(file) {
        $('.progress-box .progress-bar > div').css('width', parseInt(file.percentUploaded) + '%');
        $('.progress-box .progress-num > b').html(SWFUpload.speed.formatPercent(file.percentUploaded));
        if(parseInt(file.percentUploaded) == 100) {
            // 如果上传完成了
            $('.progress-box').hide();
        }
    }

    function initProgress() {
        $('.progress-box').show();
        $('.progress-box .progress-bar > div').css('width', '0%');
        $('.progress-box .progress-num > b').html('0%');
    }

    function successAction(fileInfo) {
        var up_path = fileInfo.path;
        var up_width = fileInfo.width;
        var up_height = fileInfo.height;
        var _up_width,_up_height;
        if(up_width > 120) {
            _up_width = 120;
            _up_height = _up_width*up_height/up_width;
        }
        $(".logobox .resizebox").css({width: _up_width, height: _up_height});
        $(".logobox .resizebox > img").attr('src', up_path);
        $(".logobox .resizebox > img").attr('width', _up_width);
        $(".logobox .resizebox > img").attr('height', _up_height);
    }

    var swfImageUpload;
    $(document).ready(function() {
        var settings = {
            flash_url : "Widget/swfupload/swfupload.swf",
            flash9_url : "Widget/swfupload/swfupload_fp9.swf",
            upload_url: "upload.php",// 接受上传的地址
            file_size_limit : "5MB",// 文件大小限制
            file_types : "*.jpg;*.gif;*.png;*.jpeg;",// 限制文件类型
            file_types_description : "图片",// 说明，自己定义
            file_upload_limit : 100,
            file_queue_limit : 0,
            custom_settings : {},
            debug: false,
            // Button settings
            button_image_url: "Widget/swfupload/upload-btn.png",
            button_width: "95",
            button_height: "30 ",
            button_placeholder_id: 'uploadBtnHolder',
            button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
            button_cursor : SWFUpload.CURSOR.HAND,
            button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,

            moving_average_history_size: 40,

            // The event handler functions are defined in handlers.js
            swfupload_preload_handler : preLoad,
            swfupload_load_failed_handler : loadFailed,
            file_queued_handler : fileQueued,
            file_dialog_complete_handler: fileDialogComplete,
            upload_start_handler : function (file) {
                initProgress();
                updateProgress(file);
            },
            upload_progress_handler : function(file, bytesComplete, bytesTotal) {
                updateProgress(file);
            },
            upload_success_handler : function(file, data, response) {
                // 上传成功后处理函数
                var fileInfo = eval("(" + data + ")");
                successAction(fileInfo);
            },
            upload_error_handler : function(file, errorCode, message) {
                alert('上传发生了错误！');
            },
            file_queue_error_handler : function(file, errorCode, message) {
                if(errorCode == -110) {
                    alert('您选择的文件太大了。');
                }
            }
        };
        swfImageUpload = new SWFUpload(settings);
    });
</script>
<script>
    jQuery(function($) {
        var oTable1 = $('#sample-table').dataTable( {
            "aaSorting": [[ 1, "desc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,2,3,4,5,7,8,]}// 制定列不参与排序
            ] } );


        $('table th input:checkbox').on('click' , function(){
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function(){
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
            return 'left';
        }
    })
</script>
